set nocompatible
set backspace=indent,eol,start

syntax on
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set smartindent
set number
set ignorecase
set nobackup
set nowritebackup
set guifont=Lucida_Console:h12:cANSI
set scrolloff=5
set laststatus=2
set statusline=\ File:\ %F%m%r%=Row:\ %l/%L,\ Col:\ %c
set hlsearch
set autochdir
set hidden

command Ls !ls -l
command Pwd !pwd
command Mk !make
command Mc !make clean
command Up !svn up
command Ci !svn ci -m ""
command Di !svn diff
command St !svn status
command Tg !ctags -R .
command If !svn info
command Lg !svn log -v -l 10
command Fx %!FormatXml
command Sw w !sudo tee % > /dev/null

function InsertTabWrapper()
      let col = col('.') - 1 
      if !col || getline('.')[col - 1] !~ '\k'
          return "\<tab>"
      else
          return "\<c-n>"
      endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper()<cr>

function Help()
    if (expand("%") != "help.txt") 
        execute "vsp ~/setup/vim/help.txt"
    else
        execute "q"
    endif
endfunction
inoremap <f1> <esc>:call Help()<cr>
nnoremap <f1> :call Help()<cr>

inoremap <f3> <esc>:AT<cr>a
nnoremap <f3> :AT<cr>

inoremap <f5> <esc>gg=G<c-o><c-o>a
nnoremap <f5> gg=G<c-o><c-o>

inoremap <f6> <esc>:shell<cr>a
nnoremap <f6> :shell<cr>

inoremap <f7> <esc>gTa
nnoremap <f7> gT

inoremap <f8> <esc>gta
nnoremap <f8> gt

inoremap <f9> <esc>:tabe 
nnoremap <f9> :tabe 

inoremap <f10> <esc><c-w>wa
nnoremap <f10> <c-w>w

inoremap <f11> <esc>:sp 
nnoremap <f11> :sp 

inoremap <f12> <esc>:vsp 
nnoremap <f12> :vsp 

